package com.listeningframework.boot.constants;

import org.apache.commons.lang3.StringUtils;

/**
 * Mail Smtp Enum
 * @author lixining
 * @version $Id: MailHostEnum.java, v 0.1 2015年11月4日 下午1:20:22 lixining Exp $
 */
public enum MailHosts {
    /**
     * smtp 163
     */
    SMTP_163("smtp.163.com"),
    /**
     * smtp 163
     */
    SMTP_126("smtp.126.com"),
    /**
     * smtp qq
     */
    SMTP_QQ("smtp.qq.com"),
    /**
     * smtp aliyun
     */
    SMTP_ALIYUN("smtp.mxhichina.com");

    private String code;

    private MailHosts(String code) {
        this.code = code;
    }

    public String getCode() {
        return code;
    }

    public static boolean isMail_163(String code) {
        return StringUtils.equals(SMTP_163.code, code);
    }

    public static boolean isMail_126(String code) {
        return StringUtils.equals(SMTP_126.code, code);
    }

    public static boolean isMail_QQ(String code) {
        return StringUtils.equals(SMTP_QQ.code, code);
    }

    public static boolean isMail_ALIYUN(String code) {
        return StringUtils.equals(SMTP_ALIYUN.code, code);
    }

    public static MailHosts getMailHost(String code) {
        if (isMail_163(code)) {
            return SMTP_163;
        }
        if (isMail_126(code)) {
            return SMTP_126;
        }
        if (isMail_QQ(code)) {
            return SMTP_QQ;
        }
        if (isMail_ALIYUN(code)) {
            return SMTP_ALIYUN;
        }
        return null;
    }
}
